Translate Method
The Translate method moves or translates a graphic item in the X, Y, or Z dimensions.
Example
; Create the data.
x = FINDGEN(100)
y = 20 * Sin(x*2*!PI/25.0) * Exp(-0.01*x)
; Draw the sky and sea.
p = PLOT(x, y, XRANGE=[0,99], YRANGE=[-40,100], $
FILL_LEVEL=-40, $
AXIS_STYLE=0, MARGIN=0, DIMENSIONS=[500,400], $
BACKGROUND_COLOR="light sky blue", $
/FILL_BACKGROUND, FILL_COLOR="sea green", TRANSPARENCY=100)
; Draw the sun
e = ELLIPSE(0.9, 1, FILL_COLOR="yellow", COLOR="yellow")
; Determine the points for the boat to travel.
xx = 0.5*[-22,-19,-12,-7,8,13,18,23,0.5,0.5, $
13,8,0.5,0.5,8,3,-2,-7,0,0,-7,-12,0,0]
yy = 2*[3,-0.7,-1,-1.5,-1.5,-0.7,0.5,3,3,5, $
5,13,13,15,15,20,20,15,15,13,13,5,5,3]
; Draw the boat. Give a Z value to put the boat on top.
p1 = POLYGON(xx,yy,1,/DATA,FILL_COLOR="burlywood", CLIP=0)
; Translate p1 using data coordinates,
; translate e using device coordinates.
FOR i=1,99 DO BEGIN & $
p.SAVE, 'translatemethod_ex.gif', RES=96, /APPEND & $
p1.TRANSLATE, 1, y[i]-y[i-1], /DATA & $
e.TRANSLATE, 1,-0.5 & $
ENDFOR
p.SAVE, 'translatemethod_ex.gif', RES=96, /APPEND, /CLOSE
Syntax
graphic.Translate, X, Y, Z [, /DATA] [, /DEVICE] [, /NORMAL] [, /RESET]
Arguments
X, Y, Z
The translation along the X, Y, and Z dimensions. A value of 0 indicates no translation. If Z is not supplied then the default is 0.
Keywords
DATA
Set this keyword if the input arguments are specified in data coordinates.
DEVICE
Set this keyword if the input arguments are specified in device coordinates (pixels). This is the default behavior.
NORMAL
Set this keyword if the input arguments are specified in normalized [0, 1] coordinates.
RESET
Set this keyword to 1 to reset the translation to 0 before performing any translation. If RESET is specified then X, Y, and Z are optional.
Version History
8.0 |
Introduced |